package edu.hz.controller;

import edu.hz.dao.HomeNewestDonationDto;
import edu.hz.model.dto.*;
import edu.hz.service.DonationService;
import edu.hz.service.UserService;
import edu.hz.util.web.ApiResponse;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@CrossOrigin(origins = "*")
@RestController
public class HomeController {

    @Resource
    DonationService donationService;

    @Resource
    UserService userService;

    @GetMapping("/home/newest10")
    public ApiResponse<List<HomeNewestDonationDto>> home10EewestDonations() {
        return donationService.lastest10Donations();
    }

    @GetMapping("/home/most-contribute-projects15")
    public ApiResponse<List<HomeTopContributingDonationDto>> home15TopContributeDonations() {
        return donationService.top15ContributingProjects();
    }

    @GetMapping("/home/most-money-donations15")
    public ApiResponse<List<HomeMostMoneyDonationDto>> mostMoneyDonation15() {
        return donationService.mostMoneyDonations();
    }

    @GetMapping("/home/top-donations3")
    public ApiResponse<List<HomeTopDonationDto>> getTop3Donations() {
        return donationService.top3Donations();
    }

    @GetMapping("/home/top-contributors10")
    public ApiResponse<List<HomeMostContributePeopleDto>> getTop10Contributors() {
        return userService.top10Contributors();
    }

    @GetMapping("/home/newest-user-donations10")
    public ApiResponse<List<HomeNewestUserDonationDto>> getNewest10UserDonations() {
        return donationService.last10UserDonations();
    }

}
